import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { IECacheInterceptor } from './ie-cache-interceptor.service';
import { CookieInterceptor } from './cookie-interceptor.service';
import { ErrorInterceptor } from './error-interceptor.service';
import { API_SERVICE_BASE_URL } from '../api.service';
import * as R from 'ramda';

export let HttpInterceptorProviders = [
  { provide: HTTP_INTERCEPTORS, useClass: CookieInterceptor, multi: true },
  { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
  { provide: API_SERVICE_BASE_URL, useValue: null, multi: true },
];

if (window.ActiveXObject || 'ActiveXObject' in window) {
  const interceptor = { provide: HTTP_INTERCEPTORS, useClass: IECacheInterceptor, multi: true };
  HttpInterceptorProviders = R.concat(HttpInterceptorProviders, [interceptor]);
}
